*******Pew Research Center Poll: PEW RESEARCH CENTER JULY 2019 POLITICAL SURVEY
use "Pew Threat/Pew Data/PEW_2020_Mar.dta", clear

*Year
gen year=2020

*CC Threat
gen CCthreat1=intthreat_climatechange
recode CCthreat1 ///
		(1=3 "Major threat") ///
		(2=2 "Minor threat") ///
		(3=1 "Not a threat") ///
		(else=.), ///
		gen(CCthreat)
lab var CCthreat "Climate Change Threat"
drop CCthreat1

*Party Preference
recode d_ptyid_us ///
	(1 = 1 "GOP") ///
	(3 = 2 "Independent") ///
	(2=3 "Democrat") ///
	(else=.), ///
	gen(partyid)
lab var partyid "Party Preference"

replace partyid=3 if d_ptylean_us==2
replace partyid=1 if d_ptylean_us==1


*Gender
recode sex ///
	(1=0 "Male") ///
	(2=1 "Female") ///
	(else=.), ///
	gen(female)
lab var female "Female"	

*Age
replace age=. if age==99|age<18
lab var age "Age"

*Cohort
gen age_cohort = year-age
replace age_cohort=. if age==98|age==99|age<18
recode age_cohort ///
	(1900/1904=1 "1900-1904") ///
	(1905/1909=2 "1905-1909") ///
	(1910/1914=3 "1910-1914") ///
	(1915/1919=4 "1915-1919") ///
	(1920/1924=5 "1920-1924") ///
	(1925/1929=6 "1925-1929") ///
	(1930/1934=7 "1930-1934") ///
	(1935/1939=8 "1935-1939") ///
	(1940/1944=9 "1940-1944") ///
	(1945/1949=10 "1945-1949") ///
	(1950/1954=11 "1950-1954") ///
	(1955/1959=12 "1955-1959") ///
	(1960/1964=13 "1960-1964") ///
	(1965/1969=14 "1965-1969") ///
	(1970/1974=15 "1970-1974") ///
	(1975/1979=16 "1975-1979") ///
	(1980/1984=17 "1980-1984") ///
	(1985/1989=18 "1985-1989") ///
	(1990/1994=19 "1990-1994") ///
	(1995/1999=20 "1995-1999") ///
	(2000/2004=21 "2000-2004"), ///
	gen(cohort)
la var cohort "Age Cohort, 5 yr. intervals"

*Education
recode d_educ_us_2017 ///
	(1 2=1 "<HS") ///
	(3 4=2 "HS Graduate") ///
	(5=3 "Some College") ///
	(6 7 8=4 "College Graduate") ///
	(else=.), ///
	gen(education)
lab var education "Education"

*Racial Identity
recode racethn ///
	(1=1 "White") ///
	(2=2 "Black") ///
	(3=3 "Hispanic") ///
	(4=4 "Other") ///
	(else=.), ///
	gen(race)
lab var race "Racial Identity"

*Rural Inhabitance
/*NA IN 2020
gen DENSITY=density
recode DENSITY ///
	(1=5 "Lowest density") ///
	(2=4) ///
	(3=3 "Middle density") ///
	(4=2) ///
	(5=1 "Highest density") ///
	(else=.), ///
	gen(density1)
drop density DENSITY
rename density1 density
lab var density "Population Density"
*/

gen rural1=QS8
recode rural1 ///
	(1 2=0 "Sub/Urban") ///
	(3=1 "Rural") ///
	(else=.), ///
	gen(rural)
lab var rural "Rural Inhabitance"
drop rural1
	
*Southern State
recode cregion ///
	(1 2 4 = 0 "not South") ///
	(3=1 "South") ///
	(else=.), ///
	gen(south)
lab var south "Southern State"



*ID
gen id=ID+20200000

*Keep and save
keep CCthreat partyid female age ///
	education race rural south ///
	year weight id cohort
save "Pew Threat/Individual Recoded Pew Files/Pew_2020_Mar_Recode", replace

/*test
ologit CCthreat partyid female age education race rural south
